---
hide_table_of_contents: true
---

# Bedrock

[Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html) is a fully managed service that makes base models from Amazon and third-party model providers accessible through an API.

When this documentation was written, Bedrock supports one model for text embeddings, the Titan Embeddings G1 - Text model (amazon.titan-embed-text-v1). This model supports text retrieval, semantic similarity, and clustering. The maximum input text is 8K tokens and the maximum output vector length is 1536.

## Setup

To use this embedding, please ensure you have the Bedrock runtime client installed in your project.

```bash npm2yarn
npm i @aws-sdk/client-bedrock-runtime@^3.422.0
```

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/community
```

## Usage

The `BedrockEmbeddings` class uses the AWS Bedrock API to generate embeddings for a given text. It strips new line characters from the text as recommended.

import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/embeddings/bedrock.ts";

<CodeBlock language="typescript">{Example}</CodeBlock>

## Configuring the Bedrock Runtime Client

You can pass in your own instance of the `BedrockRuntimeClient` if you want to customize options like
`credentials`, `region`, `retryPolicy`, etc.

```typescript
import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
import { BedrockEmbeddings } from "langchain/embeddings/bedrock";

const client = new BedrockRuntimeClient({
  region: "us-east-1",
  credentials: getCredentials(),
});

const embeddings = new BedrockEmbeddings({
  client,
});
```
